/***************************************************************************
 *   KShootout - online shootout card game.                                *
 *   Copyright (C) 2008, 2009  MacJariel                                   *
 *                                                                         *
 *   KShootout is free software: you can redistribute it and/or modify     *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation, either version 3 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   KShootout is distributed in the hope that it will be useful,          *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with KShootout.  If not, see <http://www.gnu.org/licenses/>.    *
 ***************************************************************************/
#ifndef __PLAYER_H__
#define __PLAYER_H__

#include "gametypes.h"
#include <QObject>

namespace client
{
    class Game;
    class IPlayerWidget;
    class CardListWidget;
    class CharacterWidget;

    /**
     * The Player class represent a player entity in a game.
     */
    class Player
    {
    public:
        /**
         * Constructs a new player.
         * @param game The related game object.
         * @param playerData The initial player state.
         * @param playerWidget The widget that displays the player.
         */
        Player(const Game* game, const PlayerData& playerData, IPlayerWidget* playerWidget);

        /// Destroys the player.
        ~Player();

        /// Returns whether this player is on turn.
        bool isCurrent() const;

        /// Returns whether this player is requested.
        isRequested() const;

        /// Updates the player according to newPlayerData.
        void update(const PlayerData& newPlayerData);

        /// Sets whether player is on turn.
        void setCurrent(bool isCurrent);

        /// Sets whether player is requested.
        void setRequested(bool isRequested);

        /// Unplugs from the current player widget and plugs to newPlayerWidget.
        void changePlayerWidget(IPlayerWidget* newPlayerWidget);

    private:
        bool                m_isCurrent;
        bool                m_isRequested;
        const Game* const   mp_game;
        PlayerData* const   mp_playerData;
        IPlayerWidget*      mp_widget;
    };

    inline bool Player::isCurrent()
    {
        return m_isCurrent;
    }

    inline bool Player::isRequested()
    {
        return m_isRequested;
    }
}

#endif // __PLAYER_H__
